package com.zhongyu.util;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class RedisUtil {
    @Resource
    private StringRedisTemplate stringRedisTemplate;
   @Resource
    private RedisTemplate<String,Object> redisTemplate;

   public boolean setObj(String key,Object obj){
       ValueOperations<String,Object> vo=redisTemplate.opsForValue();
       vo.set(key,obj);
       return true;
   }
   public Object getObj(String key){
       ValueOperations<String,Object> vo=redisTemplate.opsForValue();
       return vo.get(key);
   }
   public boolean setStr(String key,String str){
       ValueOperations<String,String> vo=stringRedisTemplate.opsForValue();
       vo.set(key,str);
       return true;
   }
    public String getStr(String key){
        ValueOperations<String,String> vo=stringRedisTemplate.opsForValue();
        return vo.get(key);
    }

}
